/**
 * Created by loso on 2017/3/18.
 */
public class _88_MergeSortedArray {

    public static void main(String[] args) {
        _88_MergeSortedArray a = new _88_MergeSortedArray();
        int[] b = new int[]{0};
        int[] c = new int[]{1};
        a.merge(b,0,c,1);
    }

    public void merge(int[] nums1, int m, int[] nums2, int n) {
        int index1 = m - 1;
        int index2 = n - 1;
        for (int i = nums1.length - 1; i >= 0; i--) {
            if (index1 >= 0 && index2 >= 0) {
                if (nums1[index1] > nums2[index2]) {
                    nums1[i] = nums1[index1];
                    index1--;
                } else {
                    nums1[i] = nums2[index2];
                    index2--;
                }
            } else {
                if (index2>=0){
                    nums1[i] = nums2[index2];
                    index2--;
                }
            }
        }
    }
}
